#include "list.h"

Sequence::Sequence()
{}
void Sequence::insertListElement(ListElement *listElement)
{
	listElements.push_back(listElement);
}

//those classes are used for handwritten parser and also automatic generated parser
//I need to define print direction since the two works at opposite directions
void Sequence::print(int direction)
{
	int size = listElements.size();
	if(direction == FORWARD)
		for(int i=0;i<size;i++)
		{
			listElements[i]->print(direction);
			if(i!=size-1)
				std::cout<<",";
		}
	else if(direction == BACKWARD)
		for(int i=0;i<size;i++)
		{
			listElements[size-1-i]->print(direction);
			if(i!=size-1)
				std::cout<<",";
		}
	
}

List::List()
{
	sequence = NULL;
}
List::~List()
{
	delete sequence;
}
void List::insertSequence(Sequence *seq)
{
	sequence = seq;
}
void List::print(int direction)
{
	std::cout<<"[";
	if(sequence!=NULL)
		sequence->print(direction);
	std::cout<<"]";
}

ListElement::ListElement()
{}

Number::Number(int val)
{
	value = val;
}
void Number::print(int direction)
{
	std::cout<<value;
}

